/**
  ******************************************************************************
  * @file    w32f006_i2c.h
  * @author  WeiLink Technology
  * @version V1.0.0
  * @date    09/01/2020
  * @brief   This file contains all the functions prototypes for the I2C firmware 
  *              library.
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, WeiLink Technology SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT WeiLink Technology</center></h2>
  ******************************************************************************  
  */ 

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __W32F006_I2C_H
#define __W32F006_I2C_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "w32f006.h"

/** @addtogroup W32F006_StdPeriph_Driver
  * @{
  */

/** @addtogroup I2C
  * @{
  */

/* Exported types ------------------------------------------------------------*/

/** 
  * @brief  I2C Init structure definition  
  */
typedef struct
{
    uint32_t I2C_ClockSpeed;                /*!< Specifies the clock frequency. */

}I2C_InitTypeDef;

/* Exported constants --------------------------------------------------------*/

/** @defgroup I2C_Exported_Constants
  * @{
  */

/** @defgroup I2C_Speed 
  * @{
  */
#define I2C_Speed_100K                  ((uint32_t)100000)
#define I2C_Speed_400K                  ((uint32_t)400000)
#define IS_I2C_Speed(CLOCK)            (((CLOCK) == I2C_Speed_100K) || \
                                        ((CLOCK) == I2C_Speed_400K))
/**
  * @}
  */

/** @defgroup I2C_Slave_Addr 
  * @{
  */
#define IS_I2C_SLAVE_ADDR(ADDR)         (((ADDR) < 0x400))
/**
  * @}
  */

/** @defgroup I2C_Slave_Addr_Bits
  * @{
  */
#define I2C_SLAVE_ADDR_7BITS            ((uint32_t)7)
#define I2C_SLAVE_ADDR_10BITS           ((uint32_t)10)
#define IS_I2C_SLAVE_ADDR_BITS(CLOCK)  (((CLOCK) == I2C_SLAVE_ADDR_7BITS) || \
                                        ((CLOCK) == I2C_SLAVE_ADDR_10BITS))
/**
  * @}
  */

/**
  * @}
  */

/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ 

/*  Function used to set the I2C configuration to the default reset state *****/
void I2C_DeInit(void);
void I2C_Init(I2C_InitTypeDef* I2C_InitStruct);
void I2C_SetSlaveAddr(uint32_t Addr, uint32_t Bits);
void I2C_Cmd(FunctionalState NewState);
void I2C_SendData(uint8_t Data);
uint8_t I2C_ReceiveData(void);
void I2C_ACKCmd(FunctionalState NewState);
void I2C_StartCmd(void);
void I2C_StopCmd(void);
void I2C_ACKGenCallCmd(FunctionalState NewState);
void I2C_ITCmd(FunctionalState NewState);
uint8_t I2C_GetITStatus(void);
void I2C_ClearITPendingBit(void);
void I2C_ClearBusError(void);



#ifdef __cplusplus
}
#endif

#endif /*__EVP1600_I2C_H */

/**
  * @}
  */ 

/**
  * @}
  */ 

/******************* (C) COPYRIGHT WeiLink Technology *****END OF FILE****/
